<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery/jquery-1.12.4.min.js"></script>
</head>
<body>
    <h1>register</h1>
    <form>
        <input type="text" class="name">
        <input type="text" class="age">
        <input type="submit" value="register">
    </form>
    <script>
        $('input[type=submit]').on('click',(e)=>{
            e.preventDefault();
            $.ajax({
                method:'post',
                url:'http://localhost:3000/testpost',
                data:{
                    name:$('.name').val(),
                    age:$('.age').val()
                },
                success:(data)=>{
                    console.log(data);
                },
                error:(err)=>{
                    console.log(err);
                }
            })
        })
    </script>
</body>
</html>